package com.demo.gulimall.search.controller;

import com.alibaba.fastjson.JSON;
import com.demo.gulimall.common.utils.R;
import com.demo.gulimall.search.service.MallSearchService;
import com.demo.gulimall.search.vo.SearchParam;
import com.demo.gulimall.search.vo.SearchResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Chen Yuan
 * @create 2023-05-29  14:49
 */
@Slf4j
@RestController
@RequestMapping("/search")
public class SearchController {

	@Autowired
	private MallSearchService mallSearchService;

	// 上架
	@PostMapping("/save/product")
	public R searchList(@RequestBody SearchParam searchParam){
		log.info("--> SearchController.searchList - 入参 - SearchParam:{}", JSON.toJSONString(searchParam));

		SearchResult result = mallSearchService.search(searchParam);

		return R.ok(result);
	}
}
